//
//  TKYChangeStationHeaderView.m
//  StationHouseHelper
//
//  Created by apple on 2018/6/13.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYChangeStationHeaderView.h"

@interface TKYChangeStationHeaderView()

@property(nonatomic, strong)UIImageView * imageV;

@property (nonatomic, strong)UILabel *userNameLabel;

@property (nonatomic, strong)UIButton *editDataButton;

@end

@implementation TKYChangeStationHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.imageV];
        [self addSubview:self.userNameLabel];
        [self addSubview:self.editDataButton];
    }
    return self;
}

#pragma mark -- lanzy
- (UIImageView *)imageV{
    if (_imageV == nil) {
        _imageV = [[UIImageView alloc]initWithFrame:CGRectMake(kWidthScale * 20, kHeightScale *40, kWidthScale *60, kWidthScale *60)];
        _imageV.backgroundColor = [UIColor yellowColor];
        [_imageV tky_cornerWithRadius:kWidthScale *30 borderColor:nil borderWidth:0];
    }
    return _imageV;
}

- (UILabel *)userNameLabel{
    if (_userNameLabel == nil) {
        _userNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.imageV.kx_right +kWidthScale * 10, (_imageV.kx_height/2 -10)+kHeightScale *40, kWidthScale *60, kHeightScale *20)];
        _userNameLabel.text = [[NSUserDefaults standardUserDefaults]objectForKey:KUSERNAMEKEY];
        _userNameLabel.font = Font(14);
    }
    return _userNameLabel;
}

- (UIButton *)editDataButton{
    if (_editDataButton == nil) {
        _editDataButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _editDataButton.frame = CGRectMake(self.userNameLabel.kx_right +40, (_imageV.kx_height/2 -15)+kHeightScale *40, kWidthScale *99, kHeightScale *33);
        [_editDataButton setImage:[UIImage imageNamed:@"eidit"] forState:UIControlStateNormal];
        [_editDataButton setTitle:@"  编辑资料" forState:UIControlStateNormal];
        _editDataButton.titleLabel.font = Font(14);
        [_editDataButton setTitleColor:kUIColorFromRGB(666666, 1) forState:UIControlStateNormal];
        [_editDataButton addTarget:self action:@selector(editDataAction:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _editDataButton;
}

#pragma mark-- 按钮的点击事件
- (void)editDataAction:(UIButton *)button{
    if (self.editDataButtonBlock) {
        self.editDataButtonBlock(button);
    }
}


@end
